package zoo.productqnareplyboard.admin.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import zoo.productqnareplyboard.admin.dao.AdminQnAProductReplyBoardDao;
import zoo.productqnareplyboard.admin.domain.AdminProductReplyBoardCommand;

@Controller
public class AdminProductReplyBoardInsertController {

	@Autowired
	private AdminQnAProductReplyBoardDao aqnaDao;
		
	@ModelAttribute
	public AdminProductReplyBoardCommand formBacking() {
		return new AdminProductReplyBoardCommand();
	}
	@RequestMapping(value="/admin/qnadetailreply.do",method=RequestMethod.GET)
	public String process2(){ 
		return "admin_qna_detail";
	}
	
	@RequestMapping(value="/admin/qnadetailreply.do",method=RequestMethod.POST)
	public String process2(@RequestParam("bq_num") int bq_num, AdminProductReplyBoardCommand aqrCommand) {
				
				//리플등록
				aqnaDao.insertQnaBoard(aqrCommand);
				
				//답변상태변경
				aqnaDao.checkStatua(bq_num);
				
				String formView = "redirect:/admin/qnadetail.do?bq_num="+bq_num;
					
			return formView;
	}
	
}
